package com.lambda.demo.stream;

import com.lambda.demo.models.AuthorsData;

public class StreamReduceTest {
  public static void main(String[] args) {
//    计算一共有多少本书
    int count = AuthorsData.getAuthors().stream()
      .map(a -> a.getBooks().size())
      .reduce(0, (sum, bs) -> sum + bs);
    System.out.println("一共有" + count + "本书");
  }
}
